//
//  BaseTableViewController.swift
//  Weibo007
//
//  Created by 闫崇 on 15/12/13.
//  Copyright © 2015年 闫崇. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController ,VistroLoginViewDelegate{

    //用户登录标记
    var userLogin =  sharedUserAccount != nil
    //访客视图
    var vistorView : VistorLoginView?
    
    override func viewDidLoad() {
//        print("用户登录\(userLogin)")
        
        userLogin ? super.viewDidLoad() : setupVistorView()
    }
    /**
     创建访客视图
     */
    private func setupVistorView() {
        //替换跟视图 系统默认会在 nav & tab 之间建立一个视图
        vistorView = VistorLoginView()
        //设置代理
        vistorView?.delegate = self
        view = vistorView!
        
        //添加导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "vistroRegistorButtonClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "vistroLoginButtonClick")

    }
    
 
    
    func vistroRegistorButtonClick() {
        
        
    }
   
    func vistroLoginButtonClick() {
        
        //实例化 OAuth 控制器
        let vc = OAuthViewController()
        //设置导航控制器
        let nav = UINavigationController(rootViewController: vc)
        //独立的试图控制器可以 modal 出来
        presentViewController(nav, animated: true, completion: nil)
    }
    

}
